/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package master.customer_documents;

import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import master.customer_documents.object.MCustomerDocument;
import template.RegistrantionPanel;

/**
 *
 * @author iagz pc
 */
public class GUICustomerDocuments extends RegistrantionPanel {

    /**
     * Creates new form CustomerDocuments
     */
    public GUICustomerDocuments() {
        initComponents();
        initOthrs();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked") 
    private void initOthrs() {
        mcustomerdocuments = new MCustomerDocument();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtCode = new javax.swing.JTextField();
        txtDiscription = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();

        txtCode.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        txtDiscription.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel2.setText("Name :");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel5.setText("Discription :");

        txtName.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel1.setText("Code :");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
                    .addComponent(txtDiscription)
                    .addComponent(txtCode))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel1)
                    .addComponent(txtCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel2)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtDiscription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField txtCode;
    private javax.swing.JTextField txtDiscription;
    private javax.swing.JTextField txtName;
    // End of variables declaration//GEN-END:variables
 
    private master.customer_documents.object.MCustomerDocument mcustomerdocuments;
    
    @Override
    public Object initObject() {
        mcustomerdocuments.setCode(txtCode.getText());
        mcustomerdocuments.setName(txtName.getText());
        mcustomerdocuments.setDescription(txtDiscription.getText());

        return mcustomerdocuments;
    }

    @Override
    public List<Component> getOtherComponent() {
        return Arrays.asList();
    }

    @Override
    public List<Component> getIdentityComponent() {
        return Arrays.asList(
                (Component) txtCode
        );
    }

    @Override
    public List<Component> getEsentialComponent() {
        return Arrays.asList(
                (Component) txtName
        );
    }
   
    @Override
    public void getUnbindObject(Object object) {

    }

    @Override
    public void bindComponents(ArrayList<Object> list, int index) {
        mcustomerdocuments = (MCustomerDocument) list.get(index);
        txtCode.setText(mcustomerdocuments.getCode());
        txtName.setText(mcustomerdocuments.getName());
        txtDiscription.setText(mcustomerdocuments.getDescription());
    }

    @Override
    public List<Component> componentList() {
        return Arrays.asList(
                (Component) txtCode,
                (Component) txtName,
                (Component) txtDiscription
        );
    }
}
